package college;

import clientserver.Client;
import clientserver.Packet;
import clientserver.QueryResult;

public class Committee extends collegeObject {

	
	private String firstmember;
	private String secondmember;
	private String  chairman;

	
	public String getfirstMember()
	{
	return firstmember;	
	}
	public String getsecondMember()
	{
	return secondmember;	
	}
	public String getchairman()
	{
	return chairman;	
	}
	
	public Committee(Client c)
	{
		client=c;
		
		firstmember=secondmember=chairman=null;
		
	}
	
	public void readCommittee()
	{
		String q="SELECT * FROM commision";
		Packet p= new Packet(q);
		
		QueryResult qr= (QueryResult) client.SendPacketAndWait(p);
		
		if (qr.rowsize()>0)
			
		{
			firstmember=qr.getString("firstmember");
			secondmember=qr.getString("secondmember");
			chairman=qr.getString("chairman");
		}
		
	}   //readcommision
	
	
	
	
	public void setcommision(String first,String second,String chman)
	{
	firstmember=first;
	secondmember=second;
	chairman=chman;
	}
	public void savecommisiontodb()
	{
		String q="UPDATE commision SET firstmember="+general.addapostrophs(firstmember)+",secondmember="+general.addapostrophs(secondmember)+", chairman="+general.addapostrophs(chairman)+"WHERE id='1'";
		System.out.println(q);
		Packet p=new Packet(q);
		p.setUpdatePacket();
		client.SendPacketNowait(p);
		
	}
	
	
}
